/*
Copyright (C) 2010 Andrew Dieffenbach (www.puzzud.com).

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package com.puzzud.engine.input;

import com.puzzud.engine.input.InputDevice;

import java.awt.event.KeyEvent;
import java.util.Vector;

// InputKeyboard
public class InputKeyboard extends InputDevice
{
	public static final int KEY_0				= KeyEvent.VK_0;
	public static final int KEY_1				= KeyEvent.VK_1;
	public static final int KEY_2				= KeyEvent.VK_2;
	public static final int KEY_3				= KeyEvent.VK_3;
	public static final int KEY_4				= KeyEvent.VK_4;
	public static final int KEY_5				= KeyEvent.VK_5;
	public static final int KEY_6				= KeyEvent.VK_6;
	public static final int KEY_7				= KeyEvent.VK_7;
	public static final int KEY_8				= KeyEvent.VK_8;
	public static final int KEY_9				= KeyEvent.VK_9;
	
	public static final int KEY_A				= KeyEvent.VK_A;
	public static final int KEY_B				= KeyEvent.VK_B;
	public static final int KEY_C				= KeyEvent.VK_C;
	public static final int KEY_D				= KeyEvent.VK_D;
	public static final int KEY_E				= KeyEvent.VK_E;
	public static final int KEY_F				= KeyEvent.VK_F;
	public static final int KEY_G				= KeyEvent.VK_G;
	public static final int KEY_H				= KeyEvent.VK_H;
	public static final int KEY_I				= KeyEvent.VK_I;
	public static final int KEY_J				= KeyEvent.VK_J;
	public static final int KEY_K				= KeyEvent.VK_K;
	public static final int KEY_L				= KeyEvent.VK_L;
	public static final int KEY_M				= KeyEvent.VK_M;
	public static final int KEY_N				= KeyEvent.VK_N;
	public static final int KEY_O				= KeyEvent.VK_O;
	public static final int KEY_P				= KeyEvent.VK_P;
	public static final int KEY_Q				= KeyEvent.VK_Q;
	public static final int KEY_R				= KeyEvent.VK_R;
	public static final int KEY_S				= KeyEvent.VK_S;
	public static final int KEY_T				= KeyEvent.VK_T;
	public static final int KEY_U				= KeyEvent.VK_U;
	public static final int KEY_V				= KeyEvent.VK_V;
	public static final int KEY_W				= KeyEvent.VK_W;
	public static final int KEY_X				= KeyEvent.VK_X;
	public static final int KEY_Y				= KeyEvent.VK_Y;
	public static final int KEY_Z				= KeyEvent.VK_Z;
	
	public static final int KEY_BACK_SPACE			= KeyEvent.VK_BACK_SPACE;
	public static final int KEY_TAB				= KeyEvent.VK_TAB;
	public static final int KEY_ENTER			= KeyEvent.VK_ENTER;
	public static final int KEY_ESCAPE			= KeyEvent.VK_ESCAPE;
	public static final int KEY_SPACE			= KeyEvent.VK_SPACE;
	public static final int KEY_QUOTE			= KeyEvent.VK_QUOTE;
	public static final int KEY_MINUS			= KeyEvent.VK_MINUS;
	public static final int KEY_EQUAL			= KeyEvent.VK_EQUALS;
	public static final int KEY_COMMA			= KeyEvent.VK_COMMA;
	public static final int KEY_PERIOD			= KeyEvent.VK_PERIOD;
	public static final int KEY_SLASH			= KeyEvent.VK_SLASH;
	public static final int KEY_FORWARD_SLASH		= KEY_SLASH;	// Alias.
	
	public static final int KEY_SEMICOLON			= KeyEvent.VK_SEMICOLON;
	public static final int KEY_LEFTBRACKET			= KeyEvent.VK_OPEN_BRACKET;
	public static final int KEY_BACK_SLASH			= KeyEvent.VK_BACK_SLASH;
	public static final int KEY_RIGHTBRACKET		= KeyEvent.VK_CLOSE_BRACKET;
	public static final int KEY_BACK_QUOTE			= KeyEvent.VK_BACK_QUOTE;
	
	public static final int KEY_NUMPAD_0			= KeyEvent.VK_NUMPAD0;
	public static final int KEY_NUMPAD_1			= KeyEvent.VK_NUMPAD1;
	public static final int KEY_NUMPAD_2			= KeyEvent.VK_NUMPAD2;
	public static final int KEY_NUMPAD_3			= KeyEvent.VK_NUMPAD3;
	public static final int KEY_NUMPAD_4			= KeyEvent.VK_NUMPAD4;
	public static final int KEY_NUMPAD_5			= KeyEvent.VK_NUMPAD5;
	public static final int KEY_NUMPAD_6			= KeyEvent.VK_NUMPAD6;
	public static final int KEY_NUMPAD_7			= KeyEvent.VK_NUMPAD7;
	public static final int KEY_NUMPAD_8			= KeyEvent.VK_NUMPAD8;
	public static final int KEY_NUMPAD_9			= KeyEvent.VK_NUMPAD9;
	
	// TODO Figure out how to accomplish left and right of these keys.
	//#define KEY_KP_PERIOD			SDLK_KP_PERIOD
	//#define KEY_KP_DIVIDE			SDLK_KP_DIVIDE
	//#define KEY_KP_MULTIPLY		SDLK_KP_MULTIPLY
	//#define KEY_KP_MINUS			SDLK_KP_MINUS
	//#define KEY_KP_PLUS			SDLK_KP_PLUS
	//#define KEY_KP_ENTER			SDLK_KP_ENTER
	//#define KEY_KP_EQUALS			SDLK_KP_EQUALS
	
	public static final int KEY_LEFT			= KeyEvent.VK_LEFT;
	public static final int KEY_RIGHT			= KeyEvent.VK_RIGHT;
	public static final int KEY_UP				= KeyEvent.VK_UP;
	public static final int KEY_DOWN			= KeyEvent.VK_DOWN;
	
	public static final int KEY_INSERT			= KeyEvent.VK_INSERT;
	public static final int KEY_DELETE			= KeyEvent.VK_DELETE;
	public static final int KEY_HOME			= KeyEvent.VK_HOME;
	public static final int KEY_END				= KeyEvent.VK_END;
	public static final int KEY_PAGE_UP			= KeyEvent.VK_PAGE_UP;
	public static final int KEY_PAGE_DOWN			= KeyEvent.VK_PAGE_DOWN;
	
	public static final int KEY_F1			 	= KeyEvent.VK_F1;
	public static final int KEY_F2			 	= KeyEvent.VK_F2;
	public static final int KEY_F3			 	= KeyEvent.VK_F3;
	public static final int KEY_F4			 	= KeyEvent.VK_F4;
	public static final int KEY_F5			 	= KeyEvent.VK_F5;
	public static final int KEY_F6			 	= KeyEvent.VK_F6;
	public static final int KEY_F7			 	= KeyEvent.VK_F7;
	public static final int KEY_F8			 	= KeyEvent.VK_F8;
	public static final int KEY_F9			 	= KeyEvent.VK_F9;
	public static final int KEY_F10			 	= KeyEvent.VK_F10;
	public static final int KEY_F11			 	= KeyEvent.VK_F11;
	public static final int KEY_F12			 	= KeyEvent.VK_F12;
	public static final int KEY_F13			 	= KeyEvent.VK_F13;
	public static final int KEY_F14			 	= KeyEvent.VK_F14;
	public static final int KEY_F15			 	= KeyEvent.VK_F15;
	
	public static final int KEY_NUMLOCK			= KeyEvent.VK_NUM_LOCK;
	public static final int KEY_CAPSLOCK			= KeyEvent.VK_CAPS_LOCK;
	public static final int KEY_SCROLLOCK			= KeyEvent.VK_SCROLL_LOCK;
	
	// TODO Figure out how to accomplish left and right of these keys.
	//#define KEY_RIGHTSHIFT		SDLK_RSHIFT
	//#define KEY_LEFTSHIFT			SDLK_LSHIFT
	//#define KEY_RIGHTCTRL			SDLK_RCTRL
	//#define KEY_LEFTCTRL			SDLK_LCTRL
	//#define KEY_RIGHTALT			SDLK_RALT
	//#define KEY_LEFTALT			SDLK_LALT
	//#define KEY_LEFTWINDOWS		SDLK_LSUPER	/* Left "Windows" key */
	//#define KEY_RIGHTWINDOWS		SDLK_RSUPER	/* Right "Windows" key */
	
	public static final int KEY_PRINT_SCREEN		= KeyEvent.VK_PRINTSCREEN;
	//#define KEY_SYSREQ			SDLK_SYSREQ	// NOTE is this the same as previous?
	
	public static final int KEY_PAUSE			= KeyEvent.VK_PAUSE;
	//#define KEY_BREAK			SDLK_BREAK	// NOTE is this the same as previous?
	
	public static final int KEY_STATE_UP				= InputButton.BUTTON_STATE_UP;
	public static final int KEY_STATE_RELEASED			= InputButton.BUTTON_STATE_RELEASED;
	public static final int KEY_STATE_PRESSED			= InputButton.BUTTON_STATE_PRESSED;
	public static final int KEY_STATE_DOWN				= InputButton.BUTTON_STATE_DOWN;
	
	public InputKeyboard()
	{
		super();
		
		setBufferSize( 20 );	// Default size of key buffer (10 fingers * 2 key states)
	}
	
	public int getKeyState( int k )
	{
		return( getButtonState( k ) );
	}
	
	public boolean checkKey( int k )
	{
		return( checkButton( k ) );
	}
	
	public void pressKey( int k )
	{
		pressButton( k );
	}
	
	public void releaseKey( int k )
	{
		releaseButton( k );
	}
}
